package training;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class J25_5_14_Training {
    //目标和（背包问题 dp）
    public int findTargetSumWays1(int[] nums, int target) {
        int sum = 0;
        int n = nums.length;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
        }
        if(sum+target<0 || (sum+target)%2==1){
            return 0;
        }
        int key = (sum+target)/2;
        int[][] dp = new int[n+1][key+1];
        for (int i = 0; i <= n; i++) {
            dp[i][0] = 1;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= key; j++) {
                dp[i][j] = dp[i-1][j];
                if(j>=nums[i-1]){
                    dp[i][j] += dp[i-1][j-nums[i-1]];
                }
            }
        }
        return dp[n][key];
    }

    //目标和（递归dfs）
    static int val = 0;
    static int count = 0;
    static int key = 0;
    public static int findTargetSumWays(int[] nums, int target) {
        int sum = 0;
        int n = nums.length;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
        }
        if(sum+target<0 || (sum+target)%2==1){
            return 0;
        }
        key = (sum+target)/2;
        dfs(nums,0);

        return count;
    }

    public static void dfs(int[] nums,int pos ){
        if(pos == nums.length){
            if(val == key) {
                count++;
            }
            return ;
        }

            val += nums[pos];
            dfs(nums,pos+1);
            val -= nums[pos];
            dfs(nums,pos+1);

    }

    public static void main1(String[] args) {
        int[] nums = {1,1,1,1,1};
        System.out.println(findTargetSumWays(nums, 3));
    }

    //组合总和
//    public List<List<Integer>> combinationSum(int[] candidates, int target) {
//
//    }

    //游游的you
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int q = scanner.nextInt();
        while(q>0){
            q--;
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            int min = Math.min(a,Math.min(b,c));
            int val = min*2;
            if(b>=min+2){
                val += b-min-1;
            }
            System.out.println(val);
        }
    }

//    public static void main(String[] args) {
//        System.out.println('a'<='1');
//    }
}





